<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>电影宣传</title>
	</head>
	<body>
		<ul id="list_ul">
			
		</ul>
	</body>
	<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
	<script type="text/javascript">
	  
	    var dobanurl = "https://api.douban.com";
		function Getdata(){
	  	var Top250 = dobanurl +"/v2/movie/top250";
		var Jjsy  = dobanurl + "/v2/movie/coming_soon";
		var Zzsy = dobanurl+"/v2/movie/in_theaters";
	    this.Getmovie_data(Jjsy);
	    this.Getmovie_data(Top250);
	    this.Getmovie_data(Zzsy);
		console.log(this);
	  }
		Getdata()
			//获取url的参数
			function getUrl(){
				var r = window.location.search;
				if (r.indexOf("?" !=-1)) {
					var str = r.substr(1);
					strs = str.split("=");
					console.log(str);
					return strs[1]
				}
			}
			var id = getUrl()
			console.log(id);
			function Getmovie_data(url){
				$.ajax({
				type:"get",
				url:url,
				dataType:"jsonp",
				success:function(res,status){
					console.log(res);
					for(index in res.subjects){
						var mov = [];
						var movies = res.subjects[index];
						var title = movies.title;
						if(title.length >= 6){
							title = title.substring(0,6)+"..."
						}
						moe = {
							title:title,
							year:movies.year,
					    	images:movies.images.small,
					    	id:movies.id
						}
						mov.push(moe);
						if(id == moe.id){
							var str = "<li><p>"+moe.title+"</p><img src='"+moe.images+"'/><p>"+moe.year+"</p></li>"
							$("#list_ul").append(str);
						}
					}
				}
			});
			}
			
	</script>
</html>
